import request from '@/utils/request';
import qs from "qs";

export async function purchaseList(params) {
  const limit = params.pageSize;
  const page = params.current;
  const my_params = {
    limit: limit,
    page: page
  };
  Object.assign(params, my_params);
  delete params.current;
  delete params.pageSize;
  params.type = "0";
  return request('/supplyChain/purchase/page', {
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}

export async function getPurchaseDetail(params) {
  return request(`/supplyChain/purchase/listSupplier`, {
    params,
  });
}


export async function simpleApprove(data) {
  return request('supplyChain/purchase/simpleApprove', {
    method: 'POST',
    data
  });
}
export async function revoke(data) {
  return request('supplyChain/purchase/revoke', {
    method: 'POST',
    data
  });
}
export async function revokePay(data) {
  return request('supplyChain/purchase/revokePay', {
    method: 'POST',
    data
  });
}
export async function exportPay(params) {
  return request(`supplyChain/purchase/exportPay`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function exportDetails(params) {
  return request(`supplyChain/purchase/exportPurchaseDetails`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function getConfig(type) {
  return request(`/supplyChain/purchase/config?type=`+type);
}
export async function setConfig(data) {
  return request('supplyChain/purchase/config', {
    method: 'POST',
    data
  });
}
export async function reportOrders(data) {
  return request('supplyChain/purchase/report', {
    method: 'POST',
    data
  });
}
